package PhaseSixModuleone.TheFirstQuestion.code

object First {
  def count(bottle: Int, cap: Int): Int = {
    //    每次可兑换的啤酒数量
    val num = bottle / 3 + cap / 5
    if (num == 0)
      return 0
    //    兑换完还剩的瓶子数
    val bottleResidue = bottle % 3
    //    兑换完还剩的瓶盖数
    val capResidue = cap % 5
    //    递归调用
    num + count(num + bottleResidue, num + capResidue)
  }

  def main(args: Array[String]): Unit = {
    //    调用count方法
    val countSum = 50 + count(50, 50)
    println("100元一共可恰"+countSum+"瓶啤酒")
  }
}
